package chen.videoedit;

import android.os.Bundle;
import android.os.Environment;
import android.view.View;

import com.alibaba.baichuan.android.trade.AlibcTradeSDK;


/**
 * 视频添加音乐
 */
public class AddAudioActivity extends BasisActivity {


    private String audio;
    private String video;
    private String path_save;
    private VideoAudioDispose dispose;


    @Override
    public int setlayoutResID() {
        return R.layout.activity_new_audio;
    }

    @Override
    public void initialView(Bundle arg0) {
        findViewById(R.id.activity_new_audio_bt).setOnClickListener(this);

    }

    @Override
    public void setActivity() {




        //音乐时间 没有写
        audio = Environment.getExternalStorageDirectory() + "/audio.mp3";//音乐
        video = Environment.getExternalStorageDirectory() + "/test.mp4";//视频
        path_save = Environment.getExternalStorageDirectory() + "/audio_add.mp4";//音乐视频合成保持路径
        dispose = VideoAudioDispose.newVideoAudioDispose(this, video, audio, path_save);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.activity_new_audio_bt:
                MyThread thread = new MyThread();
                thread.start();
                break;
        }

    }

    class MyThread extends Thread {
        @Override
        public void run() {
            dispose.MP3toAAC(null);
            try {
                dispose.VideoADDAudio();
            } catch (Exception e) {
                e.printStackTrace();
            }
            dispose.release();
        }
    }


}
